﻿Namespace LightSwitchApplication

    Public Class NewAsset

#Region "Asset"
        Private Sub NewAsset_InitializeDataWorkspace(saveChangesTo As System.Collections.Generic.List(Of Microsoft.LightSwitch.IDataService))
            ' Write your code here.
            Me.MainAssetsTableProperty = New MainAssetsTable()
        End Sub

        Private Sub NewAsset_Saved()
            ' Write your code here.
            Me.Close(False)
            Application.Current.ShowDefaultScreen(Me.MainAssetsTableProperty)
        End Sub


        'Private Sub CheckBoxLeasedAsset_Changed()
        '    If CheckBoxLeasedAsset Then
        '        Me.MainAssetsTableProperty.LeasedAsset = New LeasedAsset
        '        Me.MainAssetsTableProperty.LeasedAsset.MainAssetsTable = MainAssetsTableProperty
        '        Me.OpenModalWindow("ModalWindowLeasedAsset")
        '        '    Me.MainAssetsTableProperty.LeasedAsset = New LeasedAsset
        '        '    Me.MainAssetsTableProperty.LeasedAsset.MainAssetsTable = MainAssetsTableProperty
        '        'Else
        '        '    Me.MainAssetsTableProperty.LeasedAsset = Nothing
        '    End If


        'End Sub

        Private Sub NewAsset_Created()
            ' Write your code here.
            With Me.MainAssetsTableProperty
                .LastModified = Now
                .LastModifiedBy = Application.Current.User.FullName
                .DateCreated = Now
                .Createdby = Application.Current.User.FullName

            End With
        End Sub



        Private Sub NewAsset_SaveError(exception As Exception, ByRef handled As Boolean)
            ' Write your code here.

        End Sub
#End Region
        

#Region "Leased Details"
        Private Sub ButtonLeasedAsset_Execute()
            ' Write your code here.

            If Me.MainAssetsTableProperty.Assetno IsNot Nothing Then
                If Me.MainAssetsTableProperty.LeasedAsset Is Nothing Then
                    Me.MainAssetsTableProperty.LeasedAsset = New LeasedAsset
                    Me.MainAssetsTableProperty.LeasedAsset.MainAssetsTable = MainAssetsTableProperty
                End If

                Me.OpenModalWindow("ModalWindowLeasedAsset")
            End If
        End Sub


        Private Sub CloseLeasedDetailWindow_Execute()
            ' Write your code here.
            Me.CloseModalWindow("ModalWindowLeasedAsset")
        End Sub

        Private Sub DeleteLeaseDetails_Execute()
            ' Write your code here.
            Me.MainAssetsTableProperty.LeasedAsset.Delete()
            Me.CloseModalWindow("ModalWindowLeasedAsset")
        End Sub
#End Region

#Region "Warranty"
        Private Sub ButtonWarrantyDetails_Execute()
            ' Write your code here.
            If Me.MainAssetsTableProperty.Assetno IsNot Nothing Then
                If Me.MainAssetsTableProperty.Warranty Is Nothing Then
                    Me.MainAssetsTableProperty.Warranty = New Warranty
                    Me.MainAssetsTableProperty.Warranty.MainAssetsTable = MainAssetsTableProperty
                End If
                Me.OpenModalWindow("ModalWindowWarrantyDetails")
            End If
        End Sub
        Private Sub CloseWarrantyDetailWindow_Execute()
            ' Write your code here.
            Me.CloseModalWindow("ModalWindowWarrantyDetails")
        End Sub

        Private Sub DeleteWarrantyDetails_Execute()
            ' Write your code here.
            Me.MainAssetsTableProperty.Warranty.Delete()
            Me.CloseModalWindow("ModalWindowWarrantyDetails")
        End Sub
#End Region

#Region "Disposed"
        Private Sub ButtonDisposalDetails_Execute()
            ' Write your code here.
            If Me.MainAssetsTableProperty.Assetno IsNot Nothing Then
                If Me.MainAssetsTableProperty.DisposedAsset Is Nothing Then
                    Me.MainAssetsTableProperty.DisposedAsset = New DisposedAsset
                    Me.MainAssetsTableProperty.DisposedAsset.MainAssetsTable = MainAssetsTableProperty
                End If
                Me.OpenModalWindow("ModalWindowDisposalDetails")
            End If
        End Sub
        Private Sub CloseDisposalDetailsWindow_Execute()
            ' Write your code here.
            Me.CloseModalWindow("ModalWindowDisposalDetails")
        End Sub

        Private Sub DeleteDisposalDetails_Execute()
            ' Write your code here.
            Me.MainAssetsTableProperty.DisposedAsset.Delete()
            Me.CloseModalWindow("ModalWindowDisposalDetails")
        End Sub
#End Region
        
        
       
    End Class



End Namespace